$.fn.dropIng=function (type,Obj) {
    this.each(function (a, b){
        b.typeDrop=0;
        if(typeof type!="undefined"){
            b.typeDrop=type;
        }
        typeof Obj.position=="undefined"?Obj.position="fixed":Obj.position;
        typeof Obj.stopPro=="undefined"?Obj.stopPro=false:Obj.stopPro;
        (typeof Obj.returnValue=="undefined")?Obj.returnValue=true:true;
        (typeof Obj.doc=="undefined")?Obj.doc=document:true;
        var zIndex=typeof Obj.zIndex=="undefined"?true:false;
        if(typeof Obj.startPoint!="undefined"){
            b.startPoint=Obj.startPoint;
        }
 
        b.endlDrop=function(){
            b.typeDrop=0;
            $(b).attr("style","");
        };
        var func=function(e){
            e.preventDefault();
            if(b.typeDrop==1){
                $(b).css({
                    left:b.startPoint.Px+ (e.clientX-b.startPoint.x)+"px",
                    top:b.startPoint.Py+ (e.clientY-b.startPoint.y)+"px"
                });
                if(zIndex){
                    $(b).css({
                        zIndex:10000
                    })
                }
                if(typeof Obj.mode!="undefined"&&Obj.mode=="process"){
                    if(typeof Obj.processMoveFun!="undefined"){
                        Obj.processMoveFun(b,b.startPoint.Px+ (e.clientX-b.startPoint.x),b.startPoint.Py+ (e.clientY-b.startPoint.y),e);
                    }else if(typeof DropMoveFun!="undefined"){
                        DropMoveFun(b,b.startPoint.Px+ (e.clientX-b.startPoint.x),b.startPoint.Py+ (e.clientY-b.startPoint.y),e);
                    }
                }else{
                    if(typeof b.moveFun!="undefined"){
                        b.moveFun(b,b.startPoint.Px+ (e.clientX-b.startPoint.x),b.startPoint.Py+ (e.clientY-b.startPoint.y),e);
                    }
                }
            }
        };
        b.deleteDrop=function(){
            $(b).off("mousedown");
            $(b).off("mouseup");
            $(Obj.doc).off("mousemove",func);
        };
        //添加鼠标按下事件
        $(b).on("mousedown",function(e){
            if(Obj.stopPro){
                e.stopPropagation();
            }
            if(Obj.returnValue==true){
                if(e.preventDefault){
                    e.preventDefault();
                }else{
                    e.returnValue=false;
                }
            }
 
            var x=0;
            var y=0;
            if(Obj.position=="fixed"){
                x=$(b).offset().left-(window.scrollX?window.scrollX:window.pageXOffset);
                y=$(b).offset().top-(window.scrollY?window.scrollY:window.pageYOffset);
            }else if(Obj.position=="absolute"){
                x= b.offsetLeft;
                y= b.offsetTop;
            }
            if(b.typeDrop==0){
                b.typeDrop=1;
                b.startPoint={
                    x: e.clientX,
                    y: e.clientY,
                    Px:x,
                    Py:y
                };
                $(b).css({
                    position:Obj.position,
                    cursor:"pointer",
                    left:parseInt(b.startPoint.Px)+"px",
                    top:parseInt(b.startPoint.Py)+"px",
                    margin:0
                });
                if(zIndex){
                    $(b).css({
                        zIndex:10000
                    })
                }
                if(typeof Obj.mode!="undefined"&&Obj.mode=="process"){
                    if(typeof Obj.processStartFun!="undefined"){
                        Obj.processStartFun(b, $(b).position().left,$(b).position().top,e);
                    }else if(typeof DropStartFun!="undefined"){
                        DropStartFun(b, $(b).position().left,$(b).position().top,e);
                    }
                }else{
                    if(typeof b.startFun!="undefined"){
                        b.startFun(b, $(b).position().left,$(b).position().top,e);
                    }
                }
            }
        });
        //添加鼠标移动事件
     
        $(Obj.doc).on("mousemove",func);
        //添加鼠标放开事件
        $(b).on("mouseup",function(e){
            e.preventDefault();
            if(b.typeDrop==1){
                b.typeDrop=0;
                if(typeof Obj.mode!="undefined"&&Obj.mode=="process"){
                    if(typeof Obj.processEndFun!="undefined"){
                        Obj.processEndFun(b, $(b).position().left,$(b).position().top,e);
                    }else if(typeof DropEndFun!="undefined"){
                        DropEndFun(b, $(b).position().left,$(b).position().top,e);
                    }
                }else{
                    if(typeof b.endFun!="undefined"){
                        b.endFun(b, $(b).position().left, $(b).position().top,e);
                    }
                }
            }
        });
    });
};